var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, n) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var n in e)
              Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
          })(e, n);
      };
      return function (e, n) {
        function a() {
          this.constructor = e;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        t(e, n),
          (e.prototype =
            null === n
              ? Object.create(n)
              : ((a.prototype = n.prototype), new a()));
      };
    })(),
  tomb = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.itemArr = []),
        e.btn_mixueDetail_close.on(Laya.Event.CLICK, e, e.onMiXueDetailDataFn),
        e.btn_buy_luoyangchan.on(Laya.Event.CLICK, e, e.onGoBuyLuoyangShovel),
        WebSocketService.addListener({
          caller: e,
          code: 1591,
          method: e.onLoadLookTombData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1412,
          method: e.onLoadGoBuyLuoYanChanFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1592,
          method: e.onLoadPublicHistoryData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1411,
          method: e.onLoadItemDetailData,
        }),
        e.btn_tanxue_one.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_two.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_three.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_four.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_five.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_six.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_seven.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_eight.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        e.btn_tanxue_nine.on(Laya.Event.CLICK, e, e.onTanXueItemDidCLick),
        (e.list_tomb_history.vScrollBarSkin = ""),
        (e.list_tomb_history.selectEnable = !0),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showTombView = function () {
        return (
          null == this.tombVC && (this.tombVC = new e()),
          WebSocketService.send({ c: 1591, d: null }),
          WebSocketService.send({ c: 1412, d: { c: 0 } }),
          WebSocketService.send({ c: 1592, d: null }),
          (this.tombVC.label_wabao_result.text = ""),
          (this.tombVC.canSelNum = 0),
          (this.tombVC.selIndex = -1),
          this.tombVC
        );
      }),
      (e.prototype.onTanXueItemDidCLick = function (t) {
        if (-1 == this.selIndex) {
          this.canSelNum <= 0 &&
            ToastView.toastView("请先去购买洛阳铲，再进行探穴！");
          var e = 0;
          "item0" == t.target.name
            ? (e = 0)
            : "item1" == t.target.name
            ? (e = 1)
            : "item2" == t.target.name
            ? (e = 2)
            : "item3" == t.target.name
            ? ((e = 3), (this.btn_tanxue_four.selected = !0))
            : "item4" == t.target.name
            ? (e = 4)
            : "item5" == t.target.name
            ? (e = 5)
            : "item6" == t.target.name
            ? (e = 6)
            : "item7" == t.target.name
            ? (e = 7)
            : "item8" == t.target.name && (e = 8);
          var n;
          this.itemArr
            ? (n = this.itemArr[e])
              ? ((this.selIndex = e),
                0 == n[0] && WebSocketService.send({ c: 1411, d: { i: n[1] } }),
                this.dealButtonStates(e, !0))
              : this.dealButtonStates(e, !1)
            : ToastView.toastView("请先购买洛阳铲");
        } else ToastView.toastView("操作频繁请稍等");
      }),
      (e.prototype.dealButtonStates = function (t, e) {
        0 == t
          ? (this.btn_tanxue_one.selected = e)
          : 1 == t
          ? (this.btn_tanxue_two.selected = e)
          : 2 == t
          ? (this.btn_tanxue_three.selected = e)
          : 3 == t
          ? (this.btn_tanxue_four.selected = e)
          : 4 == t
          ? (this.btn_tanxue_five.selected = e)
          : 5 == t
          ? (this.btn_tanxue_six.selected = e)
          : 6 == t
          ? (this.btn_tanxue_seven.selected = e)
          : 7 == t
          ? (this.btn_tanxue_eight.selected = e)
          : 8 == t && (this.btn_tanxue_nine.selected = e);
      }),
      (e.prototype.onLoadItemDetailData = function (t) {
        if (0 != t.code)
          return (
            this.dealButtonStates(this.selIndex, !1),
            (this.selIndex = -1),
            void ToastView.toastView(t.msg)
          );
        (this.selIndex = -1),
          t.msg && (this.label_wabao_result.text = t.msg),
          1 == t.data[0] && WebSocketService.send({ c: 1592, d: null });
        var e = t.data[2];
        (this.label_rest_shovel.text = "可探穴" + e + "次"),
          (this.canSelNum = e),
          (this.btn_buy_luoyangchan.visible = !(e > 0));
      }),
      (e.prototype.onGoBuyLuoyangShovel = function () {
        NormalDialog.showNormalDialog(
          "您确定要购买洛阳铲吗?",
          this,
          this.onBuyLuoYangShovel
        );
      }),
      (e.prototype.onBuyLuoYangShovel = function () {
        WebSocketService.send({ c: 1412, d: { c: 1 } });
      }),
      (e.prototype.onLoadPublicHistoryData = function (t) {
        if (0 == t.code) {
          var e = void 0;
          this.dataSource = [];
          for (var n = 0; n < t.data.length; n++) {
            var a = t.data[n];
            a &&
              ((e = {
                tomb_time: { text: a.t },
                tomb_descr: { text: a.n + "(" + a.id + ") 得到" + a.v },
              }),
              this.dataSource.push(e));
          }
          this.list_tomb_history.dataSource = this.dataSource;
        }
      }),
      (e.prototype.onLoadGoBuyLuoYanChanFn = function (t) {
        if (0 == t.code) {
          var e = t.data;
          (this.label_rest_shovel.text = "可探穴" + e[1] + "次"),
            (this.canSelNum = e[1]),
            e[1] > 0
              ? (this.btn_buy_luoyangchan.visible = !1)
              : (this.btn_buy_luoyangchan.visible = !0),
            e[2] && 1 == e[2] && WebSocketService.send({ c: 1591, d: null });
        }
        ToastView.toastView(t.msg);
      }),
      (e.prototype.onLoadLookTombData = function (t) {
        if (0 == t.code) {
          var e = t.data;
          this.itemArr = [];
          for (var n = 0; n < e.length; n++) {
            var a = e[n];
            this.itemArr.push(a), a[0] > 0 && 0;
          }
          this.dealTanBaoOperation();
        } else ToastView.toastView(t.msg);
      }),
      (e.prototype.dealTanBaoOperation = function () {
        for (var t = 0; t < this.itemArr.length; t++) {
          var e = this.itemArr[t];
          0 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_one.label = this.numberIDTransferTitle(e[0])),
                (this.btn_tanxue_one.selected = !0))
              : ((this.btn_tanxue_one.selected = !1),
                (this.btn_tanxue_one.label = "探穴" + (t + 1)))
            : 1 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_two.label = this.numberIDTransferTitle(e[0])),
                (this.btn_tanxue_two.selected = !0))
              : ((this.btn_tanxue_two.selected = !1),
                (this.btn_tanxue_two.label = "探穴" + (t + 1)))
            : 2 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_three.label = this.numberIDTransferTitle(
                  e[0]
                )),
                (this.btn_tanxue_three.selected = !0))
              : ((this.btn_tanxue_three.selected = !1),
                (this.btn_tanxue_three.label = "探穴" + (t + 1)))
            : 3 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_four.label = this.numberIDTransferTitle(
                  e[0]
                )),
                (this.btn_tanxue_four.selected = !0))
              : ((this.btn_tanxue_four.selected = !1),
                (this.btn_tanxue_four.label = "探穴" + (t + 1)))
            : 4 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_five.label = this.numberIDTransferTitle(
                  e[0]
                )),
                (this.btn_tanxue_five.selected = !0))
              : ((this.btn_tanxue_five.selected = !1),
                (this.btn_tanxue_five.label = "探穴" + (t + 1)))
            : 5 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_six.label = this.numberIDTransferTitle(e[0])),
                (this.btn_tanxue_six.selected = !0))
              : ((this.btn_tanxue_six.selected = !1),
                (this.btn_tanxue_six.label = "探穴" + (t + 1)))
            : 6 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_seven.label = this.numberIDTransferTitle(
                  e[0]
                )),
                (this.btn_tanxue_seven.selected = !0))
              : ((this.btn_tanxue_seven.selected = !1),
                (this.btn_tanxue_seven.label = "探穴" + (t + 1)))
            : 7 == t
            ? e[0] > 0
              ? ((this.btn_tanxue_eight.label = this.numberIDTransferTitle(
                  e[0]
                )),
                (this.btn_tanxue_eight.selected = !0))
              : ((this.btn_tanxue_eight.selected = !1),
                (this.btn_tanxue_eight.label = "探穴" + (t + 1)))
            : 8 == t &&
              (e[0] > 0
                ? ((this.btn_tanxue_nine.label = this.numberIDTransferTitle(
                    e[0]
                  )),
                  (this.btn_tanxue_nine.selected = !0))
                : ((this.btn_tanxue_nine.selected = !1),
                  (this.btn_tanxue_nine.label = "探穴" + (t + 1))));
        }
      }),
      (e.prototype.numberIDTransferTitle = function (t) {
        var e;
        return (
          "1" == t
            ? (e = "银币")
            : "2" == t
            ? (e = "药品")
            : "3" == t
            ? (e = "矿石")
            : "4" == t
            ? (e = "宝石")
            : "5" == t
            ? (e = "宝盒")
            : "6" == t
            ? (e = "鲜花")
            : "7" == t
            ? (e = "代金")
            : "8" == t
            ? (e = "金币")
            : "9" == t && (e = "空"),
          e
        );
      }),
      (e.prototype.onMiXueDetailDataFn = function () {
        this.removeSelf();
      }),
      e
    );
  })(ui.battlefield.tombUI);
